<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">











<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Maven Minify Plugin - Binding to a Phase in the Project Build Cycle</title>
    <style type="text/css" media="all">
      @import url("../css/maven-base.css");
      @import url("../css/maven-theme.css");
      @import url("../css/site.css");
    </style>
    <link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
          <meta name="author" content="Samuel Santos" />
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
      </head>
  <body class="composite">
    <div id="banner">
                    <span id="bannerLeft">
    
            Maven Minify Plugin
    
            </span>
                    <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="breadcrumbs">
          
  

  
    
  
  
    
            <div class="xleft">
        Last Published: 2010-04-26
                      </div>
            <div class="xright">      
  

  
    
  
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="leftColumn">
      <div id="navcolumn">
           
  

  
    
  
  
    
                   <h5>Overview</h5>
            <ul>
              
    <li class="none">
                    <a href="../index.html">Introduction</a>
          </li>
              
    <li class="none">
                    <a href="../plugin-info.html">Goals</a>
          </li>
              
    <li class="none">
                    <a href="../usage.html">Usage</a>
          </li>
          </ul>
              <h5>Examples</h5>
            <ul>
              
    <li class="none">
                    <a href="../examples/basic.html">Basic Configuration</a>
          </li>
              
    <li class="none">
              <strong>Binding to a Phase in the Project Build Cycle</strong>
        </li>
              
    <li class="none">
                    <a href="../examples/exclude.html">Exclude source files from the WAR package</a>
          </li>
          </ul>
              <h5>Project Documentation</h5>
            <ul>
              
                
              
      
            
      
            
      
            
      
            
      
            
      
            
      
            
      
            
      
            
      
              
        <li class="collapsed">
                    <a href="../project-info.html">Project Information</a>
                </li>
              
                
              
      
            
      
            
      
              
        <li class="collapsed">
                    <a href="../project-reports.html">Project Reports</a>
                </li>
          </ul>
                                           <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
            <img alt="Built by Maven" src="../images/logos/maven-feather.png"></img>
          </a>
                       
  

  
    
  
  
    
        </div>
    </div>
    <div id="bodyColumn">
      <div id="contentBox">
        <div class="section"><h2>Binding to a Phase in the Project Build Cycle</h2>
<div class="section"><h3>Configuring your <tt>pom.xml</tt></h3>
<p>By tying the goals of the plugin to a phase in the build cycle, the specified goals will run each time that phase of the build cycle is executed. Doing this can make it easier to add the plugin to your project, because it eliminates the need to run the plugin standalone.</p>
<p>To bind the minify goal of the Maven Minify Plugin to a phase in the build cycle, you will need to add the <tt>execution</tt> tag with the phase set to the build phase and the <tt>goal</tt> set to minify. For example, using <tt>process-resources</tt> in the phase will force the minify goal to run each time this phase of the build cycle occurs.</p>
<div class="source"><pre>&lt;project&gt;
  ...
  &lt;build&gt;
    &lt;plugins&gt;
      ...
      &lt;plugin&gt;
        &lt;groupId&gt;com.samaxes.maven&lt;/groupId&gt;
        &lt;artifactId&gt;maven-minify-plugin&lt;/artifactId&gt;
        &lt;version&gt;1.2-SNAPSHOT&lt;/version&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;id&gt;default-minify&lt;/id&gt;
            &lt;phase&gt;process-resources&lt;/phase&gt;
            &lt;configuration&gt;
              &lt;cssSourceFiles&gt;
                &lt;param&gt;file-1.css&lt;/param&gt;
                ...
                &lt;param&gt;file-n.css&lt;/param&gt;
              &lt;/cssSourceFiles&gt;
              &lt;jsSourceFiles&gt;
                &lt;param&gt;file-1.js&lt;/param&gt;
                ...
                &lt;param&gt;file-n.js&lt;/param&gt;
              &lt;/jsSourceFiles&gt;
            &lt;/configuration&gt;
            &lt;goals&gt;
              &lt;goal&gt;minify&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;
      ...
    &lt;/plugins&gt;
  &lt;/build&gt;
  ...
&lt;/project&gt;</pre>
</div>
</div>
<div class="section"><h3>From the command-line</h3>
<p>Create a package containing the new files:</p>
<div class="source"><pre>mvn package</pre>
</div>
</div>
</div>

      </div>
    </div>
    <div class="clear">
      <hr/>
    </div>
    <div id="footer">
      <div class="xright">&#169;  
          2010
    
          samaxes
          
  

  
    
  
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
  </body>
</html>
